<?php if ($field->isPartial()): ?>
    <?php include_partial('dos/' . $name, array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?>
<?php elseif ($field->isComponent()): ?>
    <?php include_component('dos', $name, array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?>
<?php else: ?>
    <div class="<?php echo $class ?><?php $form[$name]->hasError() and print ' errors' ?>">
        <?php echo $form[$name]->renderError() ?>
        <div>
            <?php echo $form[$name]->renderLabel($label) ?>


            <?php if ($name == "university_id") { ?>
                <div class="content" style="float: left; padding-left: 0px;">
                    <?php echo $form[$name]->render($attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes) ?></div>
                <div>                
                    <a class="add_ajax" href="javascript:void(0)" onclick="LoadForm('<?php echo url_for("university/new") ?>','<?php echo url_for("university/Universities_list") ?>','select#dos_university_id',800)"  style="cursor: pointer; padding: 5px 5px 5px 11px;"><img width="20px" src="<?php echo image_path("add.png") ?>" /></a>                
                </div>

                <div class="clear"></div>   
            <?php } elseif ($name == "course_id") { ?>
                <div class="content" style="float: left; padding-left: 0px;">
                    <?php echo $form[$name]->render($attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes) ?></div>
                <div>                
                    <a class="add_ajax" href="javascript:void(0)"  onclick="LoadForm('<?php echo url_for("course/new") ?>','<?php echo url_for("course/course_list") ?>','select#dos_course_id',200)" style="cursor: pointer; padding: 5px 5px 5px 11px;"><img width="20px" src="<?php echo image_path("add.png") ?>" /></a>                
                </div>
                <div class="clear"></div>  
            <?php } else { ?>
                <div class="content">
                    <?php echo $form[$name]->render($attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes) ?></div>
            <?php } ?>
            <?php if ($help): ?>
                <div class="help"><?php echo __($help, array(), 'messages') ?></div>
            <?php elseif ($help = $form[$name]->renderHelp()): ?>
                <div class="help"><?php echo $help ?></div>
            <?php endif; ?>
        </div>
    </div>
<?php endif; ?>

<script>

    function LoadForm(link,list,id,height){
    
   
        var win = window.open(link,"popupWindow", "width=700","height="+height);   
        
               
        var pollTimer = window.setInterval(function() {
            if (win.closed !== false) { 
                window.clearInterval(pollTimer);
                
                getList(list,id);
            }
        }, 200);
    
    }
    
    
    function getList(list,id){
        $.getJSON(list, function(data){
                   
            var html = '';
            var len = data.length;
            html += '<option selected="selected" value=""></option>';
            for (var i = 0; i < len; i++) {
                       
                html += '<option value="' + data[i].id + '">' + data[i].name_en + '</option>';
                      
            }
            var old_value = $(id).val();
            $(id).html(html);
            $(id).val(old_value);
        });
    }



</script>
